package com.clon;

import java.util.StringJoiner;
// 克隆
public class User implements Cloneable{
    //游戏角色
    private int id;
    //用户名
    private String Username;
    //密码
    private String Password;
    //游戏图片
    private String path;
    //游戏进度
    private int[] data;

    public User() {
    }

    public User(int id, String username, String password, String path, int[] data) {
        this.id = id;
        this.Username = username;
        this.Password = password;
        this.path = path;
        this.data = data;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getUsername() {
        return Username;
    }

    public void setUsername(String username) {
        Username = username;
    }

    public String getPassword() {
        return Password;
    }

    public void setPassword(String password) {
        Password = password;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public int[] getData() {
        return data;
    }

    public void setData(int[] data) {
        this.data = data;
    }
    public String toString(){
        try {
            return "id:"+id+" username:"+Username+" password:"+Password+" path:"+path+" data:"+arrToString();
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException(e);
        }
    }

    public Object arrToString() throws CloneNotSupportedException {
        StringJoiner sj = new StringJoiner(",","[","]");
        for (int i = 0; i < data.length; i++){
            sj.add(data[i]+"");
        }
        return sj.toString();

    }
    @Override
    public Object clone() throws CloneNotSupportedException{
        //相当于父类中的clone方法
        //相当于让java帮我们克隆一个对象，并让对象返回
        return super.clone();
    }






















}
